package com.ibuonline.b2b.entity;

import java.io.Serializable;

public class CmsProdGuide implements Serializable, Comparable<CmsProdGuide>  {

	private static final long serialVersionUID = -6020893310480726900L;

	//fields
	private java.lang.Integer id;
	private java.lang.Integer catId;
	private java.lang.Integer parentId;
	private java.lang.Integer catLevel;
	private java.lang.Integer displayOrder;

	//default constructor
	public CmsProdGuide() {
	}

	//getter
	public java.lang.Integer getId() {
		return id;
	}
	public java.lang.Integer getCatId() {
		return catId;
	}
	public java.lang.Integer getParentId() {
		return parentId;
	}
	public java.lang.Integer getCatLevel() {
		return catLevel;
	}
	public java.lang.Integer getDisplayOrder() {
		return displayOrder;
	}

	//setter
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public void setCatId(java.lang.Integer catId) {
		this.catId = catId;
	}
	public void setParentId(java.lang.Integer parentId) {
		this.parentId = parentId;
	}
	public void setCatLevel(java.lang.Integer catLevel) {
		this.catLevel = catLevel;
	}
	public void setDisplayOrder(java.lang.Integer displayOrder) {
		this.displayOrder = displayOrder;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof CmsProdGuide))
			return false;

		final CmsProdGuide cmsProdGuide = (CmsProdGuide)other;
		if (!this.id.equals(cmsProdGuide.getId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(id).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("CmsProdGuide[")
			.append("id=").append(id).append(", ")
			.append("catId=").append(catId).append(", ")
			.append("parentId=").append(parentId).append(", ")
			.append("catLevel=").append(catLevel).append(", ")
			.append("displayOrder=").append(displayOrder).append("]").toString();
	}
	///###########
	public String getCategoryName(){
		if (catId == null) {
            return null;
        }
        return com.ibuonline.b2b.common.SysCache.getCategory(catId).getName();
	}
	@Override
	public int compareTo(CmsProdGuide o) {
		if(this.displayOrder > o.displayOrder) {
			return 1;
		} else if(this.displayOrder < o.displayOrder) {
			return -1;
		} 
		return 0;
	}
	public int getLevel() {
		return 1;
	}
}